package com.sendables;

import java.awt.Color;
import java.awt.Graphics;

import com.exception.IllegalPackageException;

public class Circle extends Shape {

	public Circle(int clientId, Color c, DoodlePoint start, int height, int width, byte filled, byte temporary)
	{
		super(clientId, c, start, height, width, filled, temporary);
	}

	public Circle()
	{
		super();
	}

	// public static void main(String[] args)
	// {
	// Square s = new Square(23, Color.green, new DoodlePoint(23, 2121), 2232, 454, Shape.HOLLOW, Shape.TEMPORARY);
	// byte[] b = new byte[s.getAlloc()];
	// s.writeByteRepresentation(b, new int[] { 0 });
	// Util.print(b, " ");
	// Square ss = (Square) new Square().parse(b, new int[] { 0 });
	// System.out.println(s);
	// System.out.println(ss);
	// }

	public void paint(Graphics g)
	{
		g.setColor(c);
		if (filled == FILLED)
		{
			g.fillOval(start.getX(), start.getY(), width, height);

		} else
		{
			g.drawOval(start.getX(), start.getY(), width, height);
		}
	}

	@Override
	public void writeByteRepresentation(byte[] b, int[] offset)
	{
		b[offset[0]++] = Sendable.CIRCLE;
		super.writeByteRepresentation(b, offset);
	}

	public String toString()
	{
		return getClass().getCanonicalName() + super.toString();
	}

	public Sendable parse(byte[] b, int[] offset) throws IllegalPackageException
	{
		if (b[offset[0]++] != Sendable.CIRCLE)
			throw new IllegalPackageException("Trying to parse something that isnt a line in class: Circle");
		parseSuper(b, offset);
		return this;
	}

	@Override
	public int getAlloc()
	{
		return super.getAlloc();
	}

}
